package scalaLearning.part4

object PartialFunc3 {
  def main(args: Array[String]): Unit = {
    val list=List(1,2,3,4,1.2,2.4,"abc")
    //偏函数的简写形式1
    def partialFunc2: PartialFunction[Any,Int]= {
      case i:Int => i+1
      case j:Double => (j*2).toInt
    }
    val list2: List[Int] = list.collect(partialFunc2)
    println("list2="+list2)
    //偏函数的简写形式2
    val list3=list.collect{
      case i:Int => i+1
      case j:Double => (j*2).toInt
    }
    println("list3="+list3)
  }
}
